package etr.bk.gui;

import etr.bk.gui.rpan.*;
import etr.bk.gui.lpan.*;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JPanel;
import javax.swing.JToolBar;

import org.h2.jdbc.JdbcSQLException;

import etr.bk.db.WorkDBInfo;

public class CPanel extends JPanel
{
	private LPanel lPanel;
	private RPanel rPanel;
	
	private JButton buttonAdd; 
	private JButton buttonEd;
	private JButton buttonSv;
	private JButton buttonDel;
	private JButton buttonCancel;
	
	private MainListener mListener;
	
	public CPanel()
	{
		Dimension dim = new Dimension(10, 10);
		this.setLayout(new BorderLayout());
		
		
		
		this.mListener = MainListener.getListener();
		
		//--------------------TOOLBAR-----------------------------
		
		JToolBar toolBar = new JToolBar("Still draggable");
		toolBar.setFloatable(false);
		toolBar.setBackground(Color.lightGray);
		
		dim.setSize(50, 30);
		
		this.buttonAdd = new JButton("Add");
		this.buttonEd = new JButton("Edit");
		this.buttonSv = new JButton("Save");
		this.buttonDel = new JButton("Del");
		this.buttonCancel = new JButton("Cancel");
		
		buttonAdd.setPreferredSize(dim);
		buttonEd.setPreferredSize(dim);
		buttonSv.setPreferredSize(dim);
		buttonDel.setPreferredSize(dim);
		buttonCancel.setPreferredSize(dim);
		
		buttonAdd.addActionListener(mListener);
		buttonEd.addActionListener(mListener);
		buttonSv.addActionListener(mListener);
		buttonDel.addActionListener(mListener);
		buttonCancel.addActionListener(mListener);
		
		this.mListener.setButtonAdd(this.buttonAdd);
		this.mListener.setButtonEd(this.buttonEd);
		this.mListener.setButtonSv(this.buttonSv);
		this.mListener.setButtonDel(this.buttonDel);
		this.mListener.setButtonCancel(this.buttonCancel);
		
		toolBar.add(buttonAdd);
		toolBar.add(buttonEd);
		toolBar.add(buttonSv);
		toolBar.add(buttonDel);
		toolBar.add(buttonCancel);
		
		toolBar.setBorder(BorderFactory.createRaisedBevelBorder());
		
		this.add(toolBar,BorderLayout.PAGE_START);
		//-------------------Panels--------------
		
		rPanel	= new RPanel();
		lPanel = new LPanel();
		
		this.add(lPanel,BorderLayout.WEST);
		this.add(rPanel, BorderLayout.CENTER);
		
		//------------------------------------------------------------------

	}

}
